package com.saltlux.storm.study.bbs;

import java.util.List;

public class BBSManager {
	private BoardDAO _boardDAO;
	private ArticleDAO _articleDAO;
	private CommentDAO _commentDAO;// 한글

	public void setBoardDAO(BoardDAO boardDAO) {
		_boardDAO = boardDAO;
	}

	public void createBoard(BoardDTO boardDTO) {
		_boardDAO.put(boardDTO);
	}

	public void deleteBoardById(String id) {
		_boardDAO.deleteById(id);
	}

	public void findBoardById(String id) {
		_boardDAO.findById(id);
	}

	public void modifyBoard(BoardDTO boardDTO) {
		_boardDAO.modify(boardDTO);
	}

	public void findBoardByTitle(String keyword) {
		_boardDAO.findByTitle(keyword);
	}

	public void createArticle(BoardDTO boardDTO, ArticleDTO articleDTO) {
		articleDTO.setBoardId(boardDTO.getId());
		_articleDAO.add(articleDTO);
	}

	public void removeArticleById(String articleId) {
		_articleDAO.remove(articleId);
	}

	public void setArticleDAO(ArticleDAO articleDAO) {
		_articleDAO = articleDAO;
	}

	public List<ArticleDTO> listArticle(BoardDTO boardDTO, int start,
			int display) {
		List<ArticleDTO> articles = _articleDAO.list(boardDTO.getId(), start,
				display);
		return articles;
	}

	public ArticleDTO getArticle(String articleId) {
		return _articleDAO.get(articleId);
	}

	public void modifyArticle(ArticleDTO articleDTO) {
		_articleDAO.modify(articleDTO);
	}

	public void addComment(ArticleDTO articleDTO, CommentDTO commentDTO) {
		_commentDAO.add(articleDTO.getId(), commentDTO);
	}

	public void setCommentDAO(CommentDAO commentDAO) {
		_commentDAO = commentDAO;
	}

	public void deleteComment(String id) {
		_commentDAO.deleteById(id);
	}

	public void modifyComment(CommentDTO commentDTO) {
		_commentDAO.modify(commentDTO);
	}

}